//选择排序,最笨的
function sort(array) {
    let newArray = []
    for (let i = 0; i < array.length; i++) {
        console.log(array);
        let maxIndex = findMaxInArray(array)
        newArray.push(array[maxIndex])
        array[maxIndex] = 0
    }
    return newArray
}

function findMaxInArray(array) {
    let maxIndex = 0
    for (let i = 0; i < array.length; i++) {
        if (array[i] > array[maxIndex]) {
            maxIndex = i
        }
    }
    return maxIndex
}

let array = [2, 1, 0, 3, 8, 6, 9, 2]

console.log('2.选择排序------------------------------');
console.log('排序结果:', sort(array));
console.log('--------------------------------------');
